package com.imaker.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.imaker.domain.ActionInfo;
import com.imaker.domain.ActionOperateInfo;
import com.imaker.domain.OperateInfo;
import com.imaker.service.ActionOperateService;
import com.imaker.service.ActionService;
import com.imaker.service.OperateService;
/**
 * <p>程序名称：       ActionOperateAction</p>
 * <p>程序说明：      权限操作action</p>
 * <p>版权信息：       Copyright mayonghua</p>
 * 
 * @author：          mayonghua
 * @version：         Ver 0.1
 */
@Controller
@Scope("prototype")
public class ActionOperateAction extends BaseAction{

	@Autowired
	private ActionOperateService actionOperateService = null;
	@Autowired
	private ActionService actionService = null;
	@Autowired
	private OperateService operateService = null;
	private ActionOperateInfo actionOperateInfo;
	private List<ActionOperateInfo> actionOperateList;
	private List<ActionInfo> actionInfoList;
	private ActionInfo actionInfo;
	private String actionId;
	private OperateInfo operateInfo;
	
	/**
	 * 初始化
	 * @return
	 */
	public String init(){
		
		return SUCCESS;
	}
	
	/**
	 * 左边的类别树
	 * @return
	 */
	public String tree() throws Exception{
		actionInfoList = actionService.findAll();
		getRequest().setAttribute("actionInfoList",actionInfoList);
		return SUCCESS;
	}
	
	/**
	 * 列表显示
	 */
	public String list() throws Exception{
		page  = actionOperateService.listByPage(page);
		return SUCCESS;
	}
	
	/**
	 *查询
	 */
	public String listChildren() throws Exception {
		page = actionOperateService.listByPage(page,actionId);
		return SUCCESS;
	}
	
	
	/**
	 * 预新建
	 * @return
	 */
	public String toSave() throws Exception{
		actionInfoList = actionService.findAll();
		return SUCCESS;
	}
	
	/**
	 * 新建
	 * @return
	 */
	public String save(){
		actionOperateInfo.setAction(actionInfo);
		actionOperateService.save(actionOperateInfo);
		return SUCCESS;
	}
	
	/**
	 * 预修改
	 * @return
	 */
	public String toUpdate() throws Exception{
		actionInfoList = actionService.findAll();
		actionOperateInfo = actionOperateService.findById(actionOperateInfo.getId());
		return SUCCESS;
	}
	
	/**
	 * 修改
	 * @return
	 */
	public String update(){
		actionOperateService.update(actionOperateInfo);
		return SUCCESS;
	}
	
	/**
	 * 删除
	 * @return
	 */
	public String delete(){
		actionOperateService.delete(idList);
		return SUCCESS;
	}

	public ActionOperateService getActionOperateService() {
		return actionOperateService;
	}

	public void setActionOperateService(ActionOperateService actionOperateService) {
		this.actionOperateService = actionOperateService;
	}

	public ActionService getActionService() {
		return actionService;
	}

	public void setActionService(ActionService actionService) {
		this.actionService = actionService;
	}

	public ActionOperateInfo getActionOperateInfo() {
		return actionOperateInfo;
	}

	public void setActionOperateInfo(ActionOperateInfo actionOperateInfo) {
		this.actionOperateInfo = actionOperateInfo;
	}

	public List<ActionOperateInfo> getActionOperateList() {
		return actionOperateList;
	}

	public void setActionOperateList(List<ActionOperateInfo> actionOperateList) {
		this.actionOperateList = actionOperateList;
	}

	public List<ActionInfo> getActionInfoList() {
		return actionInfoList;
	}

	public void setActionInfoList(List<ActionInfo> actionInfoList) {
		this.actionInfoList = actionInfoList;
	}

	public String getActionId() {
		return actionId;
	}

	public void setActionId(String actionId) {
		this.actionId = actionId;
	}

	public ActionInfo getActionInfo() {
		return actionInfo;
	}

	public void setActionInfo(ActionInfo actionInfo) {
		this.actionInfo = actionInfo;
	}

	public OperateInfo getOperateInfo() {
		return operateInfo;
	}

	public void setOperateInfo(OperateInfo operateInfo) {
		this.operateInfo = operateInfo;
	}
	
}
